using System.IO;
using Newtonsoft.Json;

namespace Admin.NET.Application.Service.Config;

/// <summary>
/// 配置相关服务
/// </summary>
[ApiDescriptionSettings(Order = 460)]
public class ConfigService : IDynamicApiController, ITransient
{
    public async Task<dynamic> GetConfig()
    {
        var wwwroot = App.WebHostEnvironment.WebRootPath;
        var json = await File.ReadAllTextAsync(Path.Combine(wwwroot, "admin\\data\\pear.config.json"));
        return JsonConvert.DeserializeObject<dynamic>(json);
    }
    public async Task<dynamic> GetMenu()
    {
        var wwwroot = App.WebHostEnvironment.WebRootPath;
        var json = await File.ReadAllTextAsync(Path.Combine(wwwroot, "admin\\data\\menu.json"));
        return JsonConvert.DeserializeObject<dynamic>(json);
    }
    public async Task<dynamic> GetMessage()
    {
        var wwwroot = App.WebHostEnvironment.WebRootPath;
        var json = await File.ReadAllTextAsync(Path.Combine(wwwroot, "admin\\data\\message.json"));
        return JsonConvert.DeserializeObject<dynamic>(json);
    }

}